this._deviceName = '';
- this._networkItems = new Map();
+ this._networks = [];
this._itemSorter = new ItemSorter({
sortFunc: (one, two) => one.network.compare(two.network),
});
this._availableConnectionsChanged();
this._updateItemsVisibility();
- this.connect('destroy', () => {
- for (const net of this._networkItems.keys())
- net.destroy();
- });
+ this.connect('destroy',
+ () => this._networks.forEach(net => net.destroy()));
}
get icon_name() {
_availableConnectionsChanged() {
const connections = this._device.get_available_connections();
- for (const net of this._networkItems.keys())
- net.checkConnections(connections);
+ this._networks.forEach(net => net.checkConnections(connections));
}
_addAccessPoint(ap) {
return;
}
- let network = [...this._networkItems.keys()]
- .find(n => n.checkAccessPoint(ap));
+ let network = this._networks.find(n => n.checkAccessPoint(ap));
if (!network) {
network = new WirelessNetwork(this._device);
network.connectObject(
'notify::icon-name', () => this._resortItem(item),
'notify::is-active', () => this._resortItem(item),
+ 'destroy', () => {
+ const idx = this._networks.indexOf(network);
+ if (idx >= 0)
+ this._networks.splice(idx, 1);
+
+ this._itemSorter.delete(item);
+ item.destroy();
+ },
this);
const pos = this._itemSorter.upsert(item);
this.section.addMenuItem(item, pos);
- this._networkItems.set(network, item);
+ this._networks.push(network);
}
network.addAccessPoint(ap);
}
_removeAccessPoint(ap) {
- const network = [...this._networkItems.keys()]
- .find(n => n.removeAccessPoint(ap));
+ const network = this._networks.find(n => n.removeAccessPoint(ap));
if (!network || network.hasAccessPoints())
return;
- const item = this._networkItems.get(network);
- this._itemSorter.delete(item);
- this._networkItems.delete(network);
-
- item?.destroy();
network.destroy();
}